import 'package:flutter/material.dart';
import 'package:keyboard_actions/keyboard_actions.dart';

class HLKeyBoardActions {
  /*
  * 键盘
  * */
  static Widget keyboardActionsWidget({
    required List<FocusNode> list,
    required Widget child,
    bool tapOutsidedis = false,
  }) {
    return KeyboardActions(
      overscroll: 16,
      tapOutsideBehavior: (tapOutsidedis == false) ? TapOutsideBehavior.none : TapOutsideBehavior.opaqueDismiss,
      config: KeyboardActionsConfig(
        keyboardBarColor: Color.fromRGBO(235, 235, 235, 0.2),
        actions: List.generate(
            list.length,
            (i) => KeyboardActionsItem(
                  focusNode: list[i],
                  toolbarButtons: [
                    (node) {
                      return GestureDetector(
                        onTap: () => node.unfocus(),
                        child: const Padding(
                          padding: EdgeInsets.only(right: 16.0),
                          child: Text(
                            "关闭",
                            style: TextStyle(fontSize: 16),
                          ),
                        ),
                      );
                    },
                  ],
                )),
      ),
      child: child,
    );
  }
}
